{include file='pub/header'/}
<title>添加广告内容</title>
</head>
<body>
<div class="page-container">
    <form class="form form-horizontal" id="adv" method="post" enctype="multipart/form-data">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">广告图：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="uploader-thum-container">
                    <div id="fileList" class="uploader-list">
                        {if $item.image}
                        <img src="{$item.image}" alt="" width="100">
                        {/if}
                    </div>
                    <div id="filePicker">选择图片</div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">展示时间(单位秒)：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-text" name="time" value="{$item.time}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">是否外部链接跳转：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <label><input type="radio" name="is_out" value="1" {if $item.is_out eq 1}checked{/if}>是</label>
                <label><input type="radio" name="is_out" value="0" {if $item.is_out neq 1}checked{/if}>否</label>
            </div>
        </div>
        <div class="row cl content out_url">
            <label class="form-label col-xs-4 col-sm-2">外部链接：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" id="out_url" class="input-text" value="{$item.out_url}" name="out_url">
            </div>
        </div>

        <div class="row cl content editor">
            <label class="form-label col-xs-4 col-sm-2">内容：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <script id="editor" name="content" type="text/plain" style="width:100%;height:400px;">{$item.content}</script>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
            <button class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存信息
            </button>
            </div>
        </div>
    </form>
</div>
{include file="pub/footer"/}
<script type="text/javascript" src="__STATIC__/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="__STATIC__/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    $(function () {
        UE.getEditor('editor');
        uploadImage($("#fileList"), null, $("#adv"), 'image');
        show_out();
        $("input[type='radio']").click(function () {
            show_out();
        });
        $("#adv").validate({
            onkeyup: false,
            focusCleanup: true,
            success: "valid",
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    type: 'post',
                    success: function (res) {
                        if (1 == res.code) {
                            layer.msg(res.msg, {icon: 6, time: 1000});
                            setTimeout(function () {
                                parent.location.reload();
                            }, 888);
                        } else {
                            layer.msg(res.msg, {icon: 5, time: 1000});
                        }
                    }
                });
            }
        });
    });

    function show_out(){
        var is_out = $("input[type='radio']:checked").val();
        $(".content").hide();
        if(is_out == 1){
            $(".out_url").show();
        }else{
            $(".editor").show();
        }
    }
</script>
</body>
</html>